package net.hn.hnms.biz.meeting.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import net.hn.hnms.biz.meeting.domain.MeetingInfo;
import net.hn.hnms.biz.meeting.request.MeetingInfoReq;
import net.hn.hnms.biz.meeting.service.MeetingInfoService;
import net.hn.hnms.biz.meeting.vo.MeetingInfoVo;
import net.hn.hnms.biz.meeting.vo.MeetingPersonVo;
import net.hn.hnms.sys.common.core.domain.R;
import net.hn.hnms.sys.common.core.domain.ResponsePage;
import net.hn.hnms.sys.common.core.web.controller.BaseController;
import net.hn.hnms.sys.common.log.annotation.Log;
import net.hn.hnms.sys.common.log.enums.BusinessType;
import net.hn.hnms.sys.common.mybatis.core.page.PageQuery;
import net.hn.hnms.sys.common.satoken.config.AutoSetMineCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(value = "会议室预约", tags = {"会议室预约"})
@RestController
@RequestMapping("/meeting/info/management")
public class MeetingInfoController  extends BaseController {




    @Autowired
    private MeetingInfoService meetingInfoService;




    @ApiOperation("新增会议预约")
    @SaCheckPermission("info:management:add")
    @PostMapping("/add")
    @Log(title = "新增会议预约", businessType = BusinessType.INSERT)
    public R<Void> add(@Validated @RequestBody MeetingInfoReq meetingInfoReq) {
        return toAjax(meetingInfoService.insert(meetingInfoReq));
    }


    @ApiOperation("会议室管理列表")
    @GetMapping("/page")
    @AutoSetMineCode
    public R<ResponsePage<MeetingInfoVo>> page( PageQuery pageQuery,MeetingInfoReq meetingInfoReq) {
        return R.ok(meetingInfoService.selectPageListSql(pageQuery,meetingInfoReq ));
    }


    @ApiOperation("删除会议")
    @SaCheckPermission("info:management:delete")
    @ApiImplicitParam(name = "idList", value = "要删除的id值,用逗号间隔", required = true, allowMultiple = true, dataType = "String", paramType = "query")
    @PostMapping("delete")
    @Log(title = "删除会议", businessType = BusinessType.DELETE)
    public R<Void> delete(@RequestParam("idList") List<String> idList) {
        meetingInfoService.updateDeleteByIds(idList);
        return R.ok();
    }
    //根据id 查询
    @ApiOperation("获取会议详情")
    @GetMapping("/{id}")
    public R<MeetingInfo> detail(@PathVariable("id") String id) {
        return R.ok(meetingInfoService.selectDetailById(id));
    }

    //修改
    @ApiOperation("更新会议信息")
    @SaCheckPermission("info:management:update")
    @PostMapping("/update")
    @Log(title = "更新会议信息", businessType = BusinessType.UPDATE)
    public R<Void> update(@Validated @RequestBody MeetingInfoReq meetingInfoReq) {
        meetingInfoService.updateById(meetingInfoReq);
        return R.ok();
    }


    @ApiOperation("开始|结束会议(修改会议信息状态)")
    @SaCheckPermission("info:management:updateMeetingStatus")
    @PostMapping("/updateMeetingStatus")
    @Log(title = "开始|结束会议(修改会议信息状态)", businessType = BusinessType.UPDATE)
    public R<List<MeetingPersonVo>> updateMeeting(@Validated @RequestBody MeetingInfoReq meetingInfoReq) {

        return R.ok(  meetingInfoService.updateMeetingInfoStatusById(meetingInfoReq));
    }

    @ApiOperation("更新参会人  传会议id和userid")
    @SaCheckPermission("info:management:updateMeetingPerson")
    @PostMapping("/updateMeetingPerson")
    @Log(title = "更新参会人", businessType = BusinessType.UPDATE)
    public R<Void> updateMeetingPerson(@Validated @RequestBody MeetingInfoReq meetingInfoReq) {
        meetingInfoService.updateMeetingPersonById(meetingInfoReq);
        return R.ok();
    }
    @ApiOperation("更新会议纪要文件")
    @SaCheckPermission("info:management:updateFile")
    @PostMapping("/updateFile")
    @Log(title = "更新会议纪要文件", businessType = BusinessType.UPDATE)
    public R<Void> updateFile(@Validated @RequestBody MeetingInfoReq meetingInfoReq) {
        meetingInfoService.updateFileById(meetingInfoReq);
        return R.ok();
    }







    //上传会议纪要

    //选得时候从组织架构里选   选完之后将人名保存到postgre中

}
